package com.ext.aic.apis.gc;

import android.content.Context;

import androidx.lifecycle.LifecycleOwner;

import com.ext.aic.apis.ApiDefine;
import com.ext.aic.apis.ApiPaths;
import com.ext.aic.apis.RequestResponse;
import com.ext.aic.beans.FirstIndustry;
import com.ext.aic.beans.response.Response;
import com.ext.aic.utils.ToastyUtils;
import com.hjq.http.EasyHttp;

import java.util.List;

public class IndustryRequest {

    protected void onIndustrySuccess(List<FirstIndustry> industries) {

    }

    public void request(Context context, LifecycleOwner lifecycleOwner) {
        ApiDefine apiDefine = new ApiDefine(ApiPaths.industryList);
        EasyHttp.get(lifecycleOwner).api(apiDefine).request(new RequestResponse<Response<List<FirstIndustry>>>(context, true) {
            @Override
            protected void onSuccess(Response<List<FirstIndustry>> response) {
                if (response.getCode() == 200) {
                    onIndustrySuccess(response.getData());
                } else {
                    ToastyUtils.getInstance().show(response.getMessage());
                }
            }
        });
    }
}
